//
//  BidDetailViewController.m
//  LineMoney
//
//  Created by 尹宁 on 16/7/14.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "BidDetailViewController.h"
#import "MainSectionView.h"
#import "CompleteTableViewCell.h"
#import "BidView.h"
#import "ExchangeTwoViewViewController.h"
@interface BidDetailViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UIView *bigView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) MainSectionView *sectionView1;
@property (nonatomic, strong) MainSectionView *sectionView2;
@property (nonatomic, strong) BidView *BidView;

@end

@implementation BidDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"投标详情";
    [self creatBigView];
    [self creatSectionView];
    [self initTableView];
    [self creatBidView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;

}

- (void)creatBigView
{
    _bigView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT)];
    _bigView.backgroundColor = [UIColor whiteColor];
    _bigView.backgroundColor = HUIBACKGROUNDCOLOR;
    [self.view addSubview:_bigView];
}

- (void)creatSectionView
{
    
    self.sectionView1 = [[[NSBundle mainBundle] loadNibNamed:@"MainSectionView" owner:nil options:nil] lastObject];
    _sectionView1.frame = CGRectMake(0, 0, KSCREENWIDTH, 40 );
    _sectionView1.backgroundColor = [UIColor clearColor];
    _sectionView1.leftView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"小标题前竖条"]];
    _sectionView1.label.textColor = BACKGROUNDCOLOR;
    _sectionView1.label.text = @"招标需求";
    _sectionView1.imageV.hidden = YES;
    _sectionView1.label.backgroundColor = [UIColor clearColor];
    [_bigView addSubview:_sectionView1];
    
    
    self.sectionView2 = [[[NSBundle mainBundle] loadNibNamed:@"MainSectionView" owner:nil options:nil] lastObject];
    [_bigView addSubview:_sectionView2];
    _sectionView2.frame = CGRectMake(0, 165, KSCREENWIDTH, 40);
    _sectionView2.backgroundColor = [UIColor clearColor];
    _sectionView2.leftView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"小标题前竖条"]];
    _sectionView2.label.textColor = BACKGROUNDCOLOR;
    _sectionView2.label.text = @"我要招标";
    _sectionView2.imageV.hidden = YES;
    _sectionView2.label.backgroundColor = [UIColor clearColor];
}

- (void)creatBidView
{
    self.BidView = [[[NSBundle mainBundle] loadNibNamed:@"BidView1" owner:nil options:nil] lastObject];
    _BidView.frame = CGRectMake(0, 205, KSCREENWIDTH, 278);
    _BidView.BidButton.layer.cornerRadius = 20;
    _BidView.BidButton.layer.masksToBounds = YES;
//    _BidView.BidButton.backgroundColor = [UIColor whiteColor];
    [[self.BidView.BidButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        ExchangeTwoViewViewController *myDetail = [[ExchangeTwoViewViewController alloc] init];
        [self.navigationController pushViewController:myDetail animated:YES];
    }];
    [_bigView addSubview:_BidView];
}

- (void)initTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, _sectionView1.bounds.size.height, KSCREENWIDTH, 126) style:UITableViewStylePlain];
    [_bigView addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];// 如果没有数据下方不显示分割线
    [_tableView registerNib:[UINib nibWithNibName:@"CompleteTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CompleteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];// 去掉点击之后的阴影
    cell.MoreImage.hidden = YES;
    return cell;
    
}

//- (void)hah
//{
//    ExchangeTwoViewViewController *exchange = [[ExchangeTwoViewViewController alloc] init];
//    [self.navigationController pushViewController:exchange animated:YES];
//}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    BidDetailViewController *bidDetail = [[BidDetailViewController alloc] init];
//    [self.navigationController pushViewController:bidDetail animated:YES];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 126;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.1;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
